import java.util.Scanner;

public class ScannerDemo {
        public static void main(String[] args) {
            Scanner scan = new Scanner(System.in);

            int i = 0;
            float f = 0.0f;

            System.out.println("输入数");

            //判断是否有输入
            if (scan.hasNextInt()) {
                i = scan.nextInt();
                System.out.println("i =" + i);
            }else if(scan.hasNextFloat()){
                f= scan.nextFloat();
                System.out.println("f =" + f);
            }
            scan.close();
        }
}
